require 'net/http'
require "socket"

class Netfunc
	def Netfunc::HTTP_GET(host, path, port)
		htmlresponse = ""
		Net::HTTP.version_1_2
		Net::HTTP.start(host, port) {|http|
			htmlresponse = http.get(path)
		}

		return (htmlresponse.body)
	end

	def Netfunc::TCP_send(host, port, data)
		sock = TCPSocket.open(host, port)
		ret = sock.write(data)
		sock.close

		return (ret)
	end

	def Netfunc::TCP_recv(host, port)
		s0 = TCPServer.open(port)
		sock = s0.accept
		while buf = sock.gets
			data = data + buf
		end
		sock.close
		s0.close
		
		return (data)
	end

end

